package com.dqp.cslggroup.JWXT;

import com.dqp.cslggroup.UI.MyApplication;
import com.dqp.cslggroup.Util.SharedPreferencesUtil;
import com.dqp.cslggroup.bean.academic;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.util.Map;

class GetAcademic {
    private String url;
    private Map<String, String> acdaemic_cookies;
    private String stuNum;
    private String Authorization = SharedPreferencesUtil.getStringSp(MyApplication.getContext(), "Authorization", "");

    GetAcademic(String academic_url, Map<String, String> cookies, String sno) {
        this.url = academic_url;
        this.acdaemic_cookies = cookies;
        this.stuNum = sno;
    }

    academic Academic() throws Exception {
        Connection.Response response = Jsoup.connect(url + "/jwglxt/xsxy/xsxyqk_cxXsxyqkIndex.html?gnmkdm=N105515&layout=default&su=" + stuNum)
                .header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36")
                .cookies(acdaemic_cookies)
                .timeout(5000)
                .header("Authorization", Authorization)
                .method(Connection.Method.GET)
                .ignoreContentType(true)
                .execute();
        Document document = Jsoup.parse(response.body());
        academic academic = new academic();
        if (document!=null && !document.select("font").select("[style=font-weight: bold]").text().isEmpty()) {
//            academic.setAcademic1(document.select("font").select("[style=font-weight: bold]").text());
//            academic.setAcademic2(document.select("font:matchesOwn(^当)").text());
//            academic.setAcademic3(document.select("font:matchesOwn(^计划总)").text());
//            academic.setAcademic4(document.select("font:matchesOwn(^计划外)").text());
//            academic.setAcademic5(document.select("font:matchesOwn(^在)").text());
        }
        return academic;
    }


}
